#include <stdio.h>
#include "list.h"

typedef int Bool;
union toval
{
    int ival;
    Bool bval;
    float fval;
};
struct stu_node
{
    int key;
    int type;
    union toval val;
    struct list_head list;
};

int main(int argc, char const *argv[])
{

    struct list_head head;
    INIT_LIST_HEAD(&head);

    struct stu_node date1 = {1, 2, 10};
    struct stu_node date2 = {2, 1, 0};
    struct stu_node date3 = {3, 3};
    date3.val.fval = 22.5;
    list_add(&date1.list, &head);
    list_add(&date2.list, &head);
    list_add(&date3.list, &head);

    struct stu_node *temp;

    struct list_head *pos;
    list_for_each(pos, &head)
    {
        temp = list_entry(pos, struct stu_node, list);
        if (temp->type == 1)
            printf("%d  %d\n", temp->key, temp->val.ival);
        if (temp->type == 2)
            printf("%d  %d\n", temp->key, temp->val.bval);
        if (temp->type == 3)
            printf("%d  %.1f\n", temp->key, temp->val.fval);
    };
    // 得到第一个结点
    struct list_head *font;
    font = get_first(&head);

    struct list_head *back;
    back = get_last(&head);

    return 0;
}
